package com.duo.controller.user;

import com.duo.result.BaseResult;
import com.duo.utils.RedisUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController("userShopController")
@RequestMapping("/user/shop")
@Slf4j
public class ShopController {

    public static final String KEY = "SHOP_STATUS";

    @Autowired
    private RedisUtils redisUtils;

    /**
     * 获取店铺的营业状态
     * @return
     */
    @GetMapping("/getStatus")
    public Object getStatus(){
        Integer status = redisUtils.getCacheObject(KEY);
        String statusMessage = status == 1 ? "营业中" : "打烊中";
        log.info("获取到店铺的营业状态为：{}", statusMessage);
        return BaseResult.success("获取成功", statusMessage);
    }
}
